import java.util.*;

public class Test1 {
    public static void main(String[] args) {
        int[][] box = new int[3][3];
        for (int i = 0; i < 3; i++) {
            Arrays.fill(box[i], 1);
        }
        boolean[][] vis1 = new boolean[3][3];
        Random random = new Random();
        for (int i = 0; i < 2; i++) {
            int x = random.nextInt(3);
            int y = random.nextInt(3);
            while (!vis1[x][y]) {
                box[x][y] = 0;
                vis1[x][y] = true;
            }
        }
        int score = 0;
        Scanner in = new Scanner(System.in);
        int zeroCount = 0;
        boolean[][] vis2 = new boolean[3][3];
        for (int i = 0; i < 5; i++) {
            System.out.printf("请输入你想要翻开的位置[x,y]:(横纵坐标之间使用空格隔开):");
            int x = in.nextInt();
            int y = in.nextInt();
            while (x < 0 || x >= 3 || y < 0 || y >= 3) {
                System.out.println("您输入的位置错误，请重新输入:");
                x = in.nextInt();
                y = in.nextInt();
            }
            while (vis2[x][y]) {
                System.out.println("您已经翻过了该位置，请重新输入:");
                x = in.nextInt();
                y = in.nextInt();
            }
            vis2[x][y] = true;
            System.out.println("您翻开的位置的元素是：" + box[x][y]);
            if (box[x][y] == 0) {
                zeroCount++;
                if (zeroCount == 2) {
                    System.out.println("对不起，游戏结束，你输了！");
                    return;
                }
            } else {
                score++;
            }
        }
        System.out.println("您最终的得分是：" + score);
    }
}
